<?php

namespace Modules\Admin\Http\Requests;


class AdminPostRequest extends BaseRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username' => 'required|unique:admins|regex:/^[a-zA-Z0-9]{3,14}$/',
            'nickname' =>  'required|max:100',
            'password'  => 'required|regex:/^[a-zA-Z0-9]{4,14}$/',
            'email' => 'required|email'
        ];
    }

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize(): bool
    {
        return true;
    }

    public function messages()
    {
        return [
            'username.required' => '请输入账号！',
            'username.unique' => '用户名已存在！',
            'username.regex' => '用户名格式无效！',
            'nickname.required' => '请输入昵称！',
            'password.required' => '请输入密码！',
            'password.confirmed' => '两次密码输入不一致！',
            'password.regex' => '密码必须4到14位的数字或字母！',
            'email.required' => '请输入邮箱',

        ];
    }
}
